import 'package:common_utils/common_utils.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';

//基础控制器
class BaseController extends GetxController {
  //获取焦点
  reqFocus(FocusNode focusNode) {
    //FocusScope.of(ctx).requestFocus(focusNode);
    if (FocusManager.instance.primaryFocus!.canRequestFocus) {
      FocusManager.instance.primaryFocus?.requestFocus(focusNode);
    }
    LogUtil.e("获取焦点成功!");
  }

  //移除焦点
  clearFocus() {
    if (FocusManager.instance.primaryFocus!.hasFocus) {
      LogUtil.e("移除焦点成功!");
      //FocusScope.of(ctx).unfocus();
      FocusManager.instance.primaryFocus?.unfocus();
    }
  }
}
